<?php defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/* JoomLeague League Management and Prediction Game for Joomla!
 * Copyright (C) 2007  Robert Moss
 *  
 * Homepage: http://www.joomleague.de
 * Support: htt://www.joomleague.de/forum/
 * 
 * This file is part of JoomLeague.
 *  
 * JoomLeague is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Please note that the GPL states that any headers in files and
 * Copyright notices as well as credits in headers, source files
 * and output (screens, prints, etc.) can not be removed.
 * You can extend them with your own credits, though...
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * The "GNU General Public License" (GPL) is available at
 * http://www.gnu.org/copyleft/gpl.html.
*/ 

?>

<!-- Header with Project Name-->
<?php if ($showPlayers_config['show_project_heading'] == "1" OR $overall_config['show_project_heading'] == "1") { ?>
<div class="componentheading" <?php if ($showPlayers_config['show_print_button'] == "1" OR $overall_config['show_print_button'] == "1") echo 'style="float:left;"';?>><?php echo HTML_joomleague::showTitle($project, $overall_config['project_heading_type']); ?></div>
<!-- Druckfunktion -->
<?php if ($showPlayers_config['show_print_button'] == "1" OR $overall_config['show_print_button'] == "1") {
HTML_joomleague::PrintIcon( $row, $params, false, '' );
};?>
<!-- Druckfunktion Ende -->
<?php } ?>
<!-- Header END -->

<!-- section header e.g. ranking, results etc. -->
<table width="100%" class="contentpaneopen">
	<tr>
		<td class="contentheading"><?php echo _JL_PLAYERS_KADER;?> <?php echo $team->name;?> 
    <?php if ($showPlayers_config['show_team_shortform']==1) echo '[ '.$team->short_name.' ]' ;?></td>
	</tr>
</table>
<!-- section header END -->

<br />

<?php if ($showPlayers_config['show_team_logo']==1) {
     if (is_null($teamtool->picture)) 
      $picture="components/com_joomleague/images/placeholders/placeholder_450.png"; 
     else $picture=$teamtool->picture;
?>   
  <table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
  <tr>
    <td align="center"><img src="<?php echo $mosConfig_live_site ?>/<?php echo $picture;?>" alt="<?php  echo $team->name?>" title="<?php  echo $team->name?>" /></td>
  </tr>  
</table>
<?php } ?>

<?php 
if(trim($teamtool->description !="")){ ?>
<br />
<table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
  <tr class="sectiontableheader">
		<td><?php echo _JL_PLAYERS_KADER_INFO;?></td>
	</tr>
</table>
  <table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
  <tr>
      <td>
        <?php echo $teamtool->description;?>
      </td>
  </tr>  
</table>
<?php
} 
?>

<br /><br />
<?php

if (count($rows>0)) { ?>
<table width="96%" align="center" border="0" cellpadding="3" cellspacing="0">
<?php
  $k = 0;
  $position = "";
  for ($i=0, $n=count( $rows ); $i < $n; $i++) {
    $row = &$rows[$i];
    if($position != $row->position){
      $position = $row->position;
      $k = 0;
?>
      <tr class="sectiontableheader">
        <td colspan="6"><?php echo $position;?></td>
        <?php
      if ($showPlayers_config['show_stats']==1) {
        foreach (array_keys($eventtypes) AS $eventkey) {
    			echo '<td align="center"><img src="'.$mosConfig_live_site.'/components/com_joomleague/frontend/default/images/event_icons/'.$eventtypes[$eventkey]->icon.'" alt="'.$eventtypes[$eventkey]->name.'" title="'.$eventtypes[$eventkey]->name.'" align="top" hspace="2" /></td>';
      	}
 			}
      	?>
			<td width="30">&nbsp;</td>
      </tr>
<?php
    }
?>
    <tr class="<?php echo ($k == 0)? 'sectiontableentry1' : 'sectiontableentry2'; ?>">

      <td width="30" align="center">
<?php
if ($showPlayers_config['show_player_numbers']==1) {
	if ($showPlayers_config['player_numbers_pictures']==1 && function_exists('imagecreatefrompng')) { ?>
  <img src="<?php echo $mosConfig_live_site."/components/com_joomleague/frontend/".$project->template;?>/images/shirt.php?text=<?php echo ($row->position_number!=0) ? $row->position_number : '';?>" alt="" />
<?php
	}
	else { echo ($row->position_number!='') ? $row->position_number : '&nbsp;'; }
}
else echo '&nbsp;'; ?>
      </td>

<td width="40" align="center" nowrap="nowrap">
<?php if ($showPlayers_config['show_player_icon']==1) { ;?>
<?php
$picture = ($row->picture!=''&&!is_null($row->picture)&&file_exists($mosConfig_absolute_path.'/'.$row->picture)) ? $row->picture : $row->default_picture;
if ($picture!=''&&!is_null($picture)&&file_exists($mosConfig_absolute_path.'/'.$picture)) {
$Thumb = new PowerThumb();
$Thumb->setSrc($picture);
$Thumb->setDescription($row->description);
$Thumb->setAlt($row->firstname." ".$row->lastname);
$Thumb->setMaxHeight(30);
$Thumb->setAmpliationLink(false);
//$Thumb->setFilter("gray");
$Thumb->create();
}
?>
<?php } ;?>
</td>

      <td align="center" width="15%" nowrap="nowrap">
      <?php if ($showPlayers_config['link_player']==1) { ;?>
      <a href="<?php echo sefRelToAbs("index.php?option=com_joomleague&amp;func=showPlayer&amp;p=$project->id&amp;pid=$row->id&amp;Itemid=$Itemid");?>">
      <?php printf("<i>%s %s</i>",$row->firstname,$row->lastname);?></a>
      <?php } 
      else printf("<i>%s %s</i>",$row->firstname,$row->lastname);?>
      </td>
      <td width="10%" align="left">
    	<?php if($row->injury > 0 && $row->injury_end > $project->current_round){
        echo sprintf("<img src=\"$mosConfig_live_site/components/com_joomleague/frontend/default/images/injured.gif\" alt=\"\">");
        echo "</img>";
              }?>
    	<?php if($row->suspension > 0 && $row->suspension_end > $project->current_round){
        echo sprintf("<img src=\"$mosConfig_live_site/components/com_joomleague/frontend/default/images/suspension.gif\" alt=\"\">");
        echo "</img>";
              }?>    
      </td>     
      <td width="10%" nowrap="nowrap" align="left">
      <?php
      $query="SELECT * FROM #__joomleague_countries WHERE countries_id = ".$row->nation;
      $database->setQuery($query);
			if ($countries = $database->loadObjectList()) {
      if (file_exists($mosConfig_absolute_path."/images/joomleague/flags/".strtolower($countries[0]->countries_iso_code_2).".png")) {
	echo "<img src=\"".$mosConfig_live_site."/images/joomleague/flags/".strtolower($countries[0]->countries_iso_code_2).".png\" alt=\"".$country[$countries[0]->countries_iso_code_3]."\" title=\"".$country[$countries[0]->countries_iso_code_3]."\" align=\"top\" hspace=\"2\" /> ";
} else echo " [".$countries[0]->countries_iso_code_3."]";}
     ?>
      	</td>      
      <td width="10%" nowrap="nowrap" align="left"><?php printf("%s (%s)", mbiFormatDate($row->birthday,_JL_PLAYERS_BIRTHDATE_DATE), getAge($row->birthday)); ?></td>
      <?php
     if ($showPlayers_config['show_stats']==1) {
      foreach (array_keys($eventtypes) AS $eventkey) {
      	echo '<td align="center">';
      	echo ($events[$row->player_id][$eventkey]!=""&&$events[$row->player_id][$eventkey]>0)?$events[$row->player_id][$eventkey]:"-";
      	echo '</td>';
      } 
	 }?>
	 <td width="30">&nbsp;</td>
    </tr>
<?php
    $k = 1 - $k;
  } 
?>

</table>
<?php };?>

<!-- Print Button START -->
<?php if ($showPlayers_config['show_back_button'] > 0 OR $overall_config['show_back_button'] > 0) {;?>
<?php if ($showPlayers_config['show_back_button'] == "1" OR $overall_config['show_back_button'] == "1") echo '<div align="left">'; else echo '<div align="right">';?>
<?php
$params = & new mosParameters( '' );
$params->def( 'back_button', true );
$params->def( 'popup', false );
mosHTML::BackButton( $params );
?></div> 
<?php };?>
<!-- Print Button END -->
